#ifndef _RATIONAL_H_
#define _RATIONAL_H_

#include <iostream>

class rational {
	private:
		long numerator;
		long denumerator;

		long gcd(long a, long b) const;
		void normalize();

	public:
		rational(int numenator = 0, int denumenator = 1);

		void swap(rational &obj);
		rational & operator=(rational obj);

		rational & operator+=(const rational &obj);
		rational & operator-=(const rational &obj);
		rational & operator/=(const rational &obj);
		rational & operator*=(const rational &obj);
		rational operator-() const;

		bool more_then(const rational &obj) const;
		bool equals_to(const rational &obj) const;
		void print_rational(std::ostream & out) const;
		void read_rational(std::istream & in);

		rational invert() const;

		operator double() const;
};

bool operator==(const rational &obj1, const rational &obj2);
bool operator!=(const rational &obj1, const rational &obj2);
bool operator>=(const rational &obj1, const rational &obj2);
bool operator<=(const rational &obj1, const rational &obj2);
bool operator>(const rational &obj1, const rational &obj2);
bool operator<(const rational &obj1, const rational &obj2);

rational operator+(rational obj1, const rational &obj2);
rational operator-(rational obj1, const rational &obj2);
rational operator*(rational obj1, const rational &obj2);
rational operator/(rational obj1, const rational &obj2);

std::ostream & operator<<(std::ostream & out, const rational &obj);
std::istream & operator>>(std::istream & in, rational &obj);

#endif /* _RATIONAL_H_ */
